﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using VonaJobs.DAL.DAO;

namespace VonaJobs.DAL.Gatway
{
    public class SeekerGateway : DBGateway
    {
        public string SaveNewSeeker(Seeker seeker)
        {
            try
            {
                ConnectionObj.Open();
                CommandObj.CommandText =
                    string.Format("insert into tblSeeker values(@SeekerUserId,@University,@DOB,@Education,@Major,@Experience,@Age,@Skills,@Gender,@Resume)");
                CommandObj.Parameters.Clear();
                CommandObj.Parameters.Add("@SeekerUserId", SqlDbType.Int).Value = seeker.SeekerUser.Id;
                CommandObj.Parameters.Add("@University", SqlDbType.NVarChar).Value = seeker.University;
                CommandObj.Parameters.Add("@DOB", SqlDbType.DateTime).Value = seeker.DOB;
                CommandObj.Parameters.Add("@Education", SqlDbType.NVarChar).Value = seeker.Education;
                CommandObj.Parameters.Add("@Major", SqlDbType.NVarChar).Value = seeker.Major;
                CommandObj.Parameters.Add("@Age", SqlDbType.Int).Value = seeker.Age;
                CommandObj.Parameters.Add("@Skills", SqlDbType.NVarChar).Value = seeker.Skills;
                CommandObj.Parameters.Add("@Gender", SqlDbType.NVarChar).Value = seeker.Gender;
                CommandObj.Parameters.Add("@Resume", SqlDbType.Int).Value = seeker.Resume;
                CommandObj.ExecuteNonQuery();
                return "New seeker created successfully";
            }
            catch (Exception)
            {
                throw new Exception("Message Not Send, Server Error !");
            }
            finally
            {
                if (ConnectionObj != null && ConnectionObj.State == ConnectionState.Open)
                {
                    ConnectionObj.Close();
                }

            }
        }
    }
}